package
{

public class Path extends Item
{
	public var from:int;
	public var to:int;
	public var control:int=-1;
	
	public function Path()
	{
		super();
	}
	
	
	public function splitPath(point:Object):void{
		var p:Path=new Path();
		p.from=point.id;
		p.to=this.to;
		this.to=point.id;
		canvas.addPoint(point);
		
		//add to canvas
		p.id=canvas.getNewId();
		canvas.addPath(p);
	}
	
	public function identical(path:Path):Boolean{
		if(to==path.to && from==path.from){
			return true;
		}else if(to==path.from && from==path.to){
			return true;
		}
		
		return false;
	}
	
	public function containsID(id:int):Boolean{
		if(to==id)return true;
		if(from==id)return true;
		return false;
	}
	public function contains(p:Object):Boolean{
		if(to==p.id)return true;
		if(from==p.id)return true;
		return false;
	}
	public function getDx(data:Array):Number{
		var from_point:Object=data[from];
		var to_point:Object=data[to];
		
		return to_point.x-from_point.x;
	}
	
	public function getDy(data:Array):Number{
		var from_point:Object=data[from];
		var to_point:Object=data[to];
		
		return to_point.y-from_point.y;
	}
	
	public function getDX2_plus_dy2(data:Array):Number{
		var dx:Number=getDx(data);
		var dy:Number=getDy(data);
		
		return dx*dx+dy*dy;
	}
	
}

}

